package com.ekalenchuk.module.config;

import com.ekalenchuk.module.constants.PropertiesType;
import com.ekalenchuk.module.utils.Utils;

public class SocialAppSettingsFacebookImpl implements SocialAppSettings {

	private static final SocialAppSettings APPLICATION_SETTINGS = new SocialAppSettingsFacebookImpl();

	private SocialAppSettingsFacebookImpl() {

	}

	public static SocialAppSettings getApplicationSettings() {
		return APPLICATION_SETTINGS;
	}

	private String getCallbackPath() {
		return Utils.getProperty(PropertiesType.FACEBOOK, "callback.url");
	}

	private String getDomainName() {
		return Utils.getProperty(PropertiesType.APPLICATION, "app.host");
	}

	public String getAppId() {
		return Utils.getProperty(PropertiesType.FACEBOOK, "api.id");
	}

	public String getAppSecret() {
		return Utils.getProperty(PropertiesType.FACEBOOK, "api.key");
	}

	private String getHttpProtocol() {
		return Utils.getProperty(PropertiesType.APPLICATION, "app.protocol");
	}

	public String getCallbackUrl() {
		StringBuilder address = new StringBuilder();
		address.append(getHttpProtocol()).append("://")
		.append(getDomainName()).append("/")
		.append(getCallbackPath());
		return address.toString();
	}

}
